Ext.require([
    //'Ext.form.*',
    //'Ext.layout.container.Column',
    //'Ext.tab.Panel'
    '*'
]);

Ext.onReady(function() {
    console.log(11);
    Ext.QuickTips.init();//needed to load pretty quick tip roll overs
    Ext.Direct.addProvider(
        TestAction
    );
    var bd = Ext.getBody();

    bd.createChild({tag: 'h2', html: 'Form 1 - Very Simple'});

    var required = '<span style="color:red;font-weight:bold" data-qtip="Required">*</span>';

    var basicInfoForm = Ext.widget({
        xtype: 'form',
        layout: 'form',
        collapsible: true,
        id: 'simpleForm',
        frame: true,
        title: 'Simple Form',
        bodyPadding: '5 5 0',
        width: 350,
        fieldDefaults: {
            msgTarget: 'side',
            labelWidth: 75
        },
        defaultType: 'textfield',
        items: [{
            fieldLabel: 'Name',
            name: 'name'
        },{
            fieldLabel: 'Email',
            name: 'email'
        },{
            fieldLabel: 'Company',
            name: 'company'
        },
        {
            fieldLabel: 'LoginName',
            name: 'loginName'
        },{
            fieldLabel: 'name',
            name: 'name'
        },{
            fieldLabel: 'password',
            name: 'password'
        },
        {
            fieldLabel: 'salt',
            name: 'salt'
        },{
            fieldLabel: 'roles',
            name: 'roles'
        },
        {
            xtype : 'radio',
            fieldLabel: '',
            name: 'locale',
            inputValue: "en",
            boxLabel : 'English',
            checked : true
        },
        {
            xtype : 'radio',
            fieldLabel: '',
            name: 'locale',
            inputValue: "es",
            boxLabel : 'Spanish'
        }],

        buttons: [{
            text: 'Save',
            handler: function(){
            	this.up('form').getForm().submit({
                    success: function(form, action){
                       if  (action.result.message && action.result.message != '')
                            Ext.Msg.alert("Form Submitted", action.result.message);
                    }
                })
            }
        },{
            text: 'Cancel',
            handler: function() {
//                this.up('form').getForm().reset();
            	console.log(TestAction.getTree('root'));
            }
        }],

                // configs for BasicForm
         api: {
             // The server-side method to call for load() requests
             load: TestAction.loadForm,
             // The server-side must mark the submit handler as a 'formHandler'
             submit: TestAction.updateForm
         },
        // specify the order for the passed params
        paramOrder: ['nameParam', 'emailParam']
    });
    basicInfoForm.render(document.body);

});
